import { cloudstorageImageUpload } from './uploadimage'
/**
 * 自定义上传图片插件
 */
class MyUploadAdapter {
    constructor(loader) {
        this.loader = loader;
    }

    async upload() {
        const data = new FormData();
        data.append("upfile", await this.loader.file);

        return new Promise((resolve, reject) => {
            cloudstorageImageUpload(data).then(res => {
                var resData = {default:res.data.viewurl}
                resolve(resData);
            }).catch(error => {
                reject(error)
            });
        });
    }
}

export default MyUploadAdapter;
/**import { cloudstorageImageUpload } from './uploadimage'

 * 自定义上传图片插件

class MyUploadAdapter {
    constructor(loader) {
        this.loader = loader;
    }

    async upload() {
        const data = new FormData();
        data.append("upfile", await this.loader.file);
        
        await cloudstorageImageUpload(data).then(response => {
            console.log(response.data)
            let imgurl = ''
            if (response.errcode == 0) {
                imgurl = response.data.viewurl
            }

            return {
                urls: '',
                default: imgurl,
            };
        })
    }
}

export default MyUploadAdapter */